{{extend 'layout.html'}}

<!-- load dojo and provide config via data attribute -->
<script src="{{=URL('static','dojo/dojo/dojo.js')}}" data-dojo-config="async: true, parseOnLoad: true"></script>


<style>

p {
	font-family: Arial,sans-serif;
	font-size: 13px;
	color: rgb(0, 0, 0);
	margin-top: 2px;
	margin-bottom: 2px;
	line-height: 24px;
	/*text-shadow: 0px 0.5px 0px rgb(48, 48, 48);*/
}

.form_grilla_pendientes {
	font-family: "Lucida Grande", sans-serif;
	font-size: 11px;
	position: relative;
}

/* styles for autoheight */
#grid {
	
	height: auto;
}
#grid .dgrid-scroller {
	position: relative;
	overflow-y: hidden;
}


has-ie-6 #grid {
	width: 100%;
	/* Give the grid a height.  Not optimal, but we'd need more JS for better. */
	height: 20em;
}

#grid .dgrid-header-scroll {
	display: none;
}
#grid .dgrid-header {
	right: 0;
}


	
</style>


<script type="text/javascript">
	
	
	
	
require(
["dojo/_base/xhr", "dojo/_base/declare",
"dojo/store/Memory", "dojo/store/Observable", 
"dgrid/Grid", "dgrid/extensions/Pagination",
"dgrid/Selection", "dgrid/Keyboard", "dgrid/GridFromHtml",
"dojo/_base/lang", "dojo/_base/declare", "dojo/dom-construct", 
"dojo/dom-form", "dgrid/test/data/base", "dojo/domReady!"],
function(xhr, declare,  
	Memory, Observable, 
	Grid, Pagination, 
	Selection, Keyboard, GridFromHtml,
	lang, declare, domConstruct, domForm){

	xhr.get({
			// URL de la request
			url: '{{=URL(r = request, c = "modificaciones", f="modificaciones_load_mis_consultas")}}',
			handleAs: "json",
			content: {
			},
			load: function(response) {
				cargar_grilla(response.data_list, response.rows);
			}
	});
	
	cargar_grilla = function(data_list, rows){
		
	data = {
		identifier: 'numero',
		label: 'numero',
		items: []
	};

	for(var i=0, l=data_list.length; i<rows; i++){
		data.items.push(lang.mixin({ id: i }, data_list[i%l]));
	}
	// global var testStore
	testStore = Observable(new Memory({data: data}));
	
	var CustomGrid = declare([Grid, Keyboard, Selection, Pagination]);
	
	getColumns2 = function(){
		return {
		fecha: 'Fecha',
		numero: 'Numero',
		nombre: 'Nombre',
		tipo: 'Tipo',
		consulta: 'Consulta',
		subconsulta: 'Subconsulta',
		comentario: 'Comentario'
		};
	};	
	
	window.grid = new CustomGrid({
		store: testStore,
		columns: getColumns2(),
		pagingLinks: false,
		pagingTextBox: false,
		firstLastArrows: true,
		pageSizeOptions: [10, 30, 50]
		}, "grid");
		

	document.getElementById("modificarSelected").onclick = function(){
		for (var i in grid.selection) {
			// Each key in the selection map is the id of the item,
			window.location = "{{=URL(c = 'modificaciones', f = 'modificaciones_modify')}}/" + i;
		}
	};
	
	};

})
</script>


<button type="button" id="modificarSelected">Modificar seleccionado</button>

<p>
	Puede ordenar las consultas que aparecen en la grilla por cualquier campo haciendo click en el titulo. 
</p>

{{=form}}

